
//新增投标线索页面
//文件下载权限申请
$(".download-icon").on('click', function () {
    //询问框
    layer.confirm('权限不足，是否申请更高权限？', {
        title: '提示信息',
        btn: ['申请', '取消'] //按钮
    }, function () {
        layer.msg('申请成功', {
            icon: 1
        });
    });
});
//文件上传统一字段
function showfile() {
    $(".hidefile").show();
    $("#ishide").val(1);
}
hidefile();
function hidefile() {
    $(".hidefile").hide();
    $("#ishide").val(0);
}

$(".clear").click(function () {
    $("#fileLevel").val("");
    $("#useRange").val("");
    $("#datetime-2").val("");
    $("#filePower").val("");
    $("#aperFileUrl").val("");
    $("#paperChargeUser").val("");
    $("#file").val("");
})
var stepId = $CertusJsonAjax.getStepInstanceId();
var processId = $CertusJsonAjax.getProInstanceId();
//所属公司
$CertusFormAjax.ajax("companyListByViewCode", {}, function (response) {
    $$scope.comp = JSON.parse(response.data);
});

$CertusFormAjax.ajax("findViewCompany", {}, function (response) {
    var data = response.data;
    if (data.indexOf("STSJT") > -1) {
        $$scope.isStsjt = true;
    }
    if (data.indexOf("STSGD") > -1) {
        $$scope.isGdxx = true;
    }
    if (data.indexOf("HFKJ") > -1) {
        $$scope.isHfkj = true;
    }
});

//查询客户
$CertusFormAjax.ajax("findComList", {}, function (response) {
    var nhlTeams = [];
    var data = response.data;
    for (var i = 0; i < data.length; i++) {
        var arr = {};
        arr.name = data[i].comName + "-----" + data[i].userName;
        arr.id = data[i].id;
        nhlTeams.push(arr);
    }
    //自动补全
    var nhl = $.map(nhlTeams, function (obj) {
        return {
            value: obj.name,
            data: { category: obj.id }
        };
    });
    var index = layer.load(1);
    $('#cus').devbridgeAutocomplete({
        lookup: nhl,
        minChars: 1,
        onSelect: function (suggestion) {
            $("#cusId").val(suggestion.data.category);
            var cusName = $("#cus").val().split("-----");
            $("#proName").val(cusName[0]);
        },
        showNoSuggestionNotice: true,
        noSuggestionNotice: 'Sorry, no matching results'
    });
    layer.close(index)
    loadBaseInfo();
});

function formatTime(param) {
    var date = new Date(param);
    var content = $.fn.dlshouwen.grid.tools.dateFormat(date, "yyyy-MM-dd");
    return content;
}

function ckIsN(value) {
    if (value == "N") {
        $("#pdLine").find("input[type='checkbox']").each(function (i, n) {
            if ($(n).val() != "N") {
                $(n).attr("checked", false);
            }
        });
    } else {
        $("#pdLine").find("input[type='checkbox']").each(function (i, n) {
            if ($(n).val() == "N") {
                $(n).attr("checked", false);
            }
        });
    }
}

var delL = [];
var newMoneyArr = [];
function loadBaseInfo() {
    $CertusFormAjax.ajax("getPdlines", {}, function (response) {
        $$scope.dd = response.data;

        $CertusFormAjax.ajax("getProFiles",{},function (response) {
            var data = response.data;
            $$scope.wjList = data;
        });

        $CertusFormAjax.ajax("findStageInfo", { "processId": processId }, function (result) {
            var data = result.data.map;
            $$scope.ptype = data.proType;

            if (data.proType == "XS") {
                $$scope.showArea = true;
                $$scope.showCus = true;
                $$scope.showCompare = true;
                $$scope.showSign = true;
                $$scope.showHk = true;
                $$scope.showPolucy = true;
                $$scope.showCompe = true;
                $$scope.showMoney = true;
                $$scope.showBudget = true;
                $$scope.showCtMoney = true;
                $$scope.showBsMoney = true;
                $$scope.showPhMoney = true;
                $$scope.showFinish = false;
                $$scope.showVersion = false;

                $$scope.cusName = data.cus_name;
                $$scope.cusId = data.cus_id;
                $("#proName").attr("placeholder", "客户名称+产品名称");
            } else if (data.proType == "ZL" || data.proType == "SW"
                || data.proType == "BM") {
                $$scope.showArea = false;
                $$scope.showCus = false;
                $$scope.showCompare = false;
                $$scope.showSign = false;
                $$scope.showHk = false;
                $$scope.showPolucy = false;
                $$scope.showCompe = false;
                $$scope.showMoney = false;
                $$scope.showBudget = false;
                $$scope.showCtMoney = true;
                $$scope.showBsMoney = true;
                $$scope.showPhMoney = true;
                $$scope.showFinish = true;
                $$scope.showVersion = false;
                if (data.proType == "BM") {
                    $("#proName").attr("placeholder", "部门+年份");
                    $("#clueLv").prop("disabled", "disabled");
                    $("#urgency").prop("disabled", "disabled");
                    $("#importance").prop("disabled", "disabled");

                    $("#datetime-5").prop("disabled", "disabled");
                    $("#datetime-6").prop("disabled", "disabled");
                }
            } else {
                $$scope.showArea = false;
                $$scope.showCus = false;
                $$scope.showCompare = false;
                $$scope.showSign = false;
                $$scope.showHk = false;
                $$scope.showPolucy = false;
                $$scope.showCompe = false;
                $$scope.showMoney = false;
                $$scope.showBudget = false;
                $$scope.showBsMoney = true;
                $$scope.showPhMoney = true;
                $$scope.showVersion = true;
                $$scope.showFinish = false;
                $("#proName").attr("placeholder", "");
            }
            $$scope.type = data.proType;
            $("#companys").val(data.comp_id);
            getRl(data.comp_id);
            $$scope.department = data.dept_id;
            $$scope.proArea = data.pro_area;
            $$scope.proName = data.pro_name;
            $$scope.clueLv = data.proLv + "";
            $$scope.isCompare = data.is_compare + "";
            $$scope.divineSignDate = data.divine_sign_date;
            $$scope.divineHkDate = data.divine_hk_date;
            $$scope.clueDesc = data.clue_desc;
            $$scope.cusPolicy = data.cus_policy;
            $$scope.competitor = data.competitor;
            $$scope.moneyDesc = data.money_desc;
            $$scope.clueApplyDesc = data.clue_apply_desc;
            $$scope.divineFinishTime = data.divine_finish_time;
            $$scope.divineVersionTime = data.divine_version_time;
            $$scope.proId = data.pro_id;
            $$scope.userId = data.user_id;
            $$scope.startTime = data.startTime;
            $$scope.endTime = data.endTime;
            $$scope.urgency = data.jurgency + "";
            $$scope.importance = data.jimportance + "";
            getDept();
            loadRt(result.data.rtList);
            loadWj(result.data.wjList);
            var arr = result.data.bugetList;
            for (var i = 0; i < arr.length; i++) {
                if (arr[i].bugetType === "预计销售额") {
                    $$scope.divineMoney = arr[i].buget;
                    $$scope.dmId = arr[i].id;
                } else if (arr[i].bugetType === "客户预算") {
                    $$scope.cusBudget = arr[i].buget;
                    $$scope.bumId = arr[i].id;
                } else if (arr[i].bugetType === "客户交际费用") {
                    $$scope.divineContactMoney = arr[i].buget;
                    $$scope.cmId = arr[i].id;
                    $$scope.dcMoneyDesc = arr[i].comments;
                    $$scope.ctStartTime = formatTime(arr[i].budgetBegin);
                    $$scope.ctEndTime = formatTime(arr[i].budgetEnd);
                } else if (arr[i].bugetType === "差旅费用") {
                    $$scope.divineBusinessMoney = arr[i].buget;
                    $$scope.bmId = arr[i].id;
                    $$scope.dbMoneyDesc = arr[i].comments;
                    $$scope.bsStartTime = formatTime(arr[i].budgetBegin);
                    $$scope.bsEndTime = formatTime(arr[i].budgetEnd);
                } else if (arr[i].bugetType === "采购费用") {
                    $$scope.divinePurchaseMoney = arr[i].buget;
                    $$scope.pmId = arr[i].id;
                    $$scope.dpMoneyDesc = arr[i].comments;
                    $$scope.phStartTime = formatTime(arr[i].budgetBegin);
                    $$scope.phEndTime = formatTime(arr[i].budgetEnd);
                }
            }

            var deptCodes = data.pd_line_codes.split(",");
            for (var i = 0; i < deptCodes.length; i++) {
                $("#pdLine").find("input[type='checkbox']").each(function (k, n) {
                    if ($(n).val() == deptCodes[i]) {
                        $(n).attr("checked", "checked");
                    }
                });
            }

            //其他费用
            for (var i = 0; i < arr.length; i++) {
                if (arr[i].isAdd == "1") {
                    newMoneyArr.push(arr[i]);
                }
            }

            var otherColumns = [
                {
                    id: 'buget',
                    title: '预算金额',
                    type: 'string',
                    width: 150,
                    columnClass: 'text-center',
                    resolution: function (value, record, column, grid, dataNo, columnNo) {
                        var content = '￥' + value + '元';
                        return content;
                      }
                }, {
                    id: 'budgetBegin',
                    title: '开始时间',
                    type: 'string',
                    width: 100,
                    columnClass: 'text-center',
                    resolution: function (value) {
                        var content = '';
                        if (value == "") {
                            return content;
                        } else {
                            var date = new Date(value);
                            content = $.fn.dlshouwen.grid.tools.dateFormat(date, "yyyy-MM-dd");
                            return content;
                        }

                    }
                }, {
                    id: 'budgetEnd',
                    title: '结束时间',
                    type: 'string',
                    width: 100,
                    columnClass: 'text-center',
                    resolution: function (value) {
                        var content = '';
                        if (value == "") {
                            return content;
                        } else {
                            var date = new Date(value);
                            content = $.fn.dlshouwen.grid.tools.dateFormat(date, "yyyy-MM-dd");
                            return content;
                        }

                    }
                }, {
                    id: 'comments',
                    title: '事由',
                    type: 'string',
                    columnClass: 'text-left'
                },
                {
                    id: 'operation',
                    title: '操作',
                    type: 'string',
                    width: 75,
                    columnClass: 'text-center',
                    resolution: function (value, record) {
                        var content = '';
                        content += '<button class="btn btn-xs btn-danger" onclick="deleteWarn(' + record.id + ');"><i class="fa fa-trash-o"></i>  删除</button>';
                        return content;
                    }
                }
            ];
            var otherOption = {
                lang: 'zh-cn',
                ajaxLoad: false,
                extraWidth: 20,
                // loadURL:'url',
                exportFileName: '其他费用',
                datas: newMoneyArr,
                columns: otherColumns,
                gridContainer: 'other1Container',
                tools: ''
            };
            var otherGrid = $.fn.dlshouwen.grid.init(otherOption);
            otherGrid.load();

            //添加其他费用
            var om = -1;
            $(".addMoney").on('click', function () {
                var bugetMoney = $("#bugetMoney").val();
                var comments = $("#comments").val();
                if (bugetMoney == null || bugetMoney == "" || bugetMoney == undefined) {
                    layer.msg('预算金额不能为空!');
                    return;
                }
                if (comments == null || comments == "" || comments == undefined) {
                    layer.msg('事由不能为空!');
                    return;
                }
                var arrn = {};
                arrn.id = om;
                arrn.buget = bugetMoney;
                arrn.comments = comments;
                var budgetBegin = $("#oStartTime").val();
                var budgetEnd = $("#oEndTime").val();
                if (budgetBegin == null || budgetBegin == "" || budgetBegin == undefined) {
                    layer.msg('开始日期不能为空!');
                    return;
                }
                if (budgetEnd == null || budgetEnd == "" || budgetEnd == undefined) {
                    layer.msg('结束日期不能为空!');
                    return;
                }
                if (new Date(budgetBegin.replace("/", "-").replace("/", "-")) >
                    new Date(budgetEnd.replace("/", "-").replace("/", "-"))) {
                    layer.msg('开始日期不能大于结束日期!');
                    return;
                }
                arrn.budgetBegin = budgetBegin;
                arrn.budgetEnd = budgetEnd;
                newMoneyArr.push(arrn);
                om--;
                otherGrid.load();
                $(".hideother").hide();

                $("#bugetMoney").val("");
                $("#oStartTime").val("");
                $("#oEndTime").val("");
                $("#comments").val("");
            });
            //删除费用
            this.deleteWarn = function (wid) {

                layer.confirm('确认删除此数据？', {
                    btn: ['确认', '取消'] //按钮
                }, function () {
                    var dArr = {};
                    for (var i = 0; i < newMoneyArr.length; i++) {
                        if (newMoneyArr[i].id == wid) {
                            dArr = newMoneyArr[i];
                            delL.push(wid);
                        }
                    }
                    newMoneyArr.splice($.inArray(dArr, newMoneyArr), 1);
                    otherGrid.load();
                    layer.msg('删除成功');
                });



            }

        });
    });
}

function findDept() {
    getDept();
}

//项目其他费用表单显示隐藏
function hideother() {
    $(".hideother").hide();
};

function showother() {
    $(".hideother").show();
};

function getDept() {
    var proType = $$scope.type;
    if (proType == "XS") {
        $CertusFormAjax.ajax("xsDeptList", { companyCode: $("#companys").val() }, function (response) {
            $$scope.dept = response.data;
        });
    } else {
        $CertusFormAjax.ajax("deptedList", { companyCode: $("#companys").val() }, function (response) {
            $$scope.dept = JSON.parse(response.data);
        });
    }

    $CertusFormAjax.ajax("findRegionList", { "compCode": $("#companys").val() }, function (response) {
        $$scope.area = response.data;
    });

    getRl($("#companys").val());
};

function getRl(companyCode){
    $CertusFormAjax.ajax("getNlxRoles",{"company":companyCode},function (response) {
        var data = response.data;
        $$scope.rlList = data;
    });
}

var fileInstantiation = {
    classCateCode: 'NBCPYZ',//选定市场类 文档
    fileClassCode: 'LCFJ' //选定合同文件
}
var fileInstantiationDisable = {
    classCateCodeDis: true, //文件类目不可修改
    fileClassCodeDis: true //文件类型不可修改
}
//调用初始化方法
initFileUpload($$scope, fileInstantiation, fileInstantiationDisable, $CertusFormAjax);

var fileId = "";
$(".toRegu").on('click', function () {
    fileUpload($scope, function (res) {
        fileId = res.data;
    }, null, CertusFormAjax);
});

function showRl() {
    $(".hiderl").show();
}


var rlData = [];
function loadRt(rtList) {
    if (rtList != "") {
        rlData = rtList;
    }
    var rlColumns = [{
        id: 'roleName',
        title: '角色',
        type: 'string',
        columnClass: 'text-center'
    },{
        id: 'rtMoney',
        title: '成本',
        type: 'string',
        columnClass: 'text-center',
        resolution: function (value, record, column, grid, dataNo, columnNo) {
            var content = '';
            if (value=="1"){
                content = "低";
            }else if (value=="2"){
                content = "中";
            }else{
                content = "高";
            }
            return content;
        }
    },{
        id: 'beginTime',
        title: '开始时间',
        type: 'date',
        format: 'yyyy-MM-dd',
        otype: 'time_stamp_ms',
        columnClass: 'text-center',
    }, {
        id: 'endTime',
        title: '结束时间',
        type: 'date',
        format: 'yyyy-MM-dd',
        otype: 'time_stamp_ms',
        columnClass: 'text-center',
    },{
        id: 'rtNum',
        title: '人天',
        type: 'string',
        columnClass: 'text-center',
    }, {
        id: 'comments',
        title: '说明',
        type: 'string',
        columnClass: 'text-center',
    }, {
        id: 'operation',
        title: '操作',
        width: 75,
        type: 'string',
        columnClass: 'text-center',
        resolution: function (value, record, column, grid, dataNo, columnNo) {
            var content = '';
            content += '<button class="btn btn-xs btn-danger" onclick="deleteRl(\'' + record.id + '\');"><i class="fa fa-trash-o"></i>  删除</button>';
            return content;
        }
    }];

    $("#rlContainer").empty();
    $("#rlToolBarContainer").empty();
    var rlOption = {
        lang: 'zh-cn',
        ajaxLoad: false,
        extraWidth: 20,
        // loadURL:'url',
        exportFileName: '人力成本列表',
        datas: rlData,
        columns: rlColumns,
        gridContainer: 'rlContainer',
        toolbarContainer: 'rlToolBarContainer',
        tools: ''
    };
    var rlGrid = $.fn.dlshouwen.grid.init(rlOption);
    rlGrid.load();
}

var rid = 1;
$(".rlSubmit").click(function () {
    var rArr = {};
    var userName = $('#rluserName option:selected').text();
    var userId = $("#rluserName").val();
    if (userName==""||userId==""){
        layer.msg("请选择角色！");
        return;
    }
    var rtMoney = $("#rtMoney").val();
    var rlBeginTime = $("#rlBeginTime").val();
    var rlEndTime = $("#rlEndTime").val();
    if (rlBeginTime==""||rlEndTime==""){
        layer.msg("请输入使用周期！");
        return;
    }
    var rtNum = daysBetween(rlBeginTime,rlEndTime);
    var rlComments = $("#rlComments").val();
    rArr.roleName = userName;
    rArr.roleId = userId;
    rArr.rtMoney = rtMoney;
    rArr.beginTime = rlBeginTime;
    rArr.endTime = rlEndTime;
    rArr.comments = rlComments;
    rArr.rtNum = rtNum;
    rArr.id = rid;
    //判断成员是否已经存在
    for(var i=0;i<rlData.length;i++){
        if (rlData[i].roleId==userId){
            layer.msg("成员已经存在！");
            return;
        }
    }
    rid++;
    rlData.push(rArr);
    $(".hiderl").hide();
    cleanRl();
    loadRt("");
});

var delRl = [];
//删除人力
function deleteRl(rid) {
    layer.confirm('确认删除此数据？', {
        btn: ['确认', '取消'] //按钮
    }, function () {
        var dArr = {};
        for (var i = 0; i < rlData.length; i++) {
            if (rlData[i].id == rid) {
                dArr = rlData[i];
                delRl.push(dArr);
            }
        }
        rlData.splice($.inArray(dArr, rlData), 1);
        layer.msg('删除成功');
        loadRt("");
    });
}

var wjData = [];
function loadWj(wjList) {
    if (wjList != "") {
        wjData = wjList;
    }
    //涉及文件
    var wjColumns = [{
        id: 'productName',
        title: '文件名称',
        type: 'string',
        columnClass: 'text-center'
    }, {
        id: 'comments',
        title: '说明',
        type: 'string',
        columnClass: 'text-center',
    }, {
        id: 'operation',
        title: '操作',
        width: 75,
        type: 'string',
        columnClass: 'text-center',
        resolution: function (value, record) {
            var content = '';
            content += '<button class="btn btn-xs btn-danger" onclick="deleteWj(\'' + record.id + '\');"><i class="fa fa-trash-o"></i>  删除</button>';
            return content;
        }
    }];

    $("#wjContainer").empty();
    $("#wjToolBarContainer").empty();
    var wjOption = {
        lang: 'zh-cn',
        ajaxLoad: false,
        extraWidth: 20,
        // loadURL:'url',
        exportFileName: '人力成本列表',
        datas: wjData,
        columns: wjColumns,
        gridContainer: 'wjContainer',
        toolbarContainer: 'wjToolBarContainer',
        tools: ''
    };
    var wjGrid = $.fn.dlshouwen.grid.init(wjOption);
    wjGrid.load();
}
var pwid = 1;
$(".wjSubmit").click(function () {
    // var wjId = $("#wjName").val();
    // if (wjId==""){
    //     layer.msg("请选择文件！");
    //     return;
    // }
    // var wjName = $('#wjName option:selected').text();
    var wjName = $("#wjName").val();
    var comments = $("#wjComments").val();
    var arr = {};
    arr.id = pwid;
    // arr.productCode = wjId;
    arr.productCode = "";
    arr.productName = wjName;
    arr.comments = comments;
    for(var i=0;i<wjData.length;i++){
        if (wjData[i].productName==wjName){
            layer.msg("文件已经存在！");
            return;
        }
    }
    pwid++;
    wjData.push(arr);
    $(".wjhider").hide();
    loadWj("");
    cleanWj();
});
var delWj = [];
function deleteWj(pwid) {
    layer.confirm('确认删除此数据？', {
        btn: ['确认', '取消'] //按钮
    }, function () {
        var dArr = {};
        for (var i = 0; i < wjData.length; i++) {
            if (wjData[i].id == pwid) {
                dArr = wjData[i];
                delWj.push(dArr);
            }
        }
        wjData.splice($.inArray(dArr, wjData), 1);
        wjGrid.load();
        layer.msg('删除成功');
        loadWj("");
    });
}

function closure() {
    $CertusFormAjax.ajax("closureClue", { "stepId": stepId, "procssId": processId }, function () {
        layer.msg("提交成功！");
        window.history.back();
    });
}

$(".submit").on('click', function () {
    if (!certusValidateNotnull()) {
        return;
    }

    if ($$scope.ptype == "XS") {
        if ($("#cusId").val() == "") {
            layer.msg("请从列表中选择客户");
            return;
        }
    }

    if ($("#company").val() == "") {
        layer.msg("请选择所属公司");
        return;
    }

    if ($("#department").val() == "") {
        layer.msg("请从列表中选择部门");
        return;
    }

    var sTime = $("#datetime-5").val();
    var endTime = $("#datetime-6").val();
    if (endTime == "") {
        layer.msg("项目周期结束日期不能为空", { time: 1000 });
        return;
    }
    if (sTime != "") {
        var startTime = new Date(sTime.replace("/", "-").replace("/", "-"));
        var endTimes = new Date(endTime.replace("/", "-").replace("/", "-"));
        if (startTime > endTimes) {
            layer.msg("项目周期开始日期不能大于结束日期", { time: 1000 });
            return;
        }
    } else {
        layer.msg("项目周期开始日期不能为空", { time: 1000 });
        return;
    }


    //客户交际费用
    var ctStartTime = $("#ctStartTime").val();
    var ctEndTime = $("#ctEndTime").val();
    if (new Date(ctStartTime.replace("/", "-").replace("/", "-"))
        > new Date(ctEndTime.replace("/", "-").replace("/", "-"))) {
        layer.msg("客户交际费用开始时间不能大于结束时间", { time: 1000 });
        return;
    }

    //差旅费用
    var bsStartTime = $("#bsStartTime").val();
    var bsEndTime = $("#bsEndTime").val();
    if (new Date(bsStartTime.replace("/", "-").replace("/", "-"))
        > new Date(bsEndTime.replace("/", "-").replace("/", "-"))) {
        layer.msg("差旅费用开始时间不能大于结束时间", { time: 1000 });
        return;
    }

    //采购费用
    var phStartTime = $("#phStartTime").val();
    var phEndTime = $("#phEndTime").val();
    if (new Date(phStartTime.replace("/", "-").replace("/", "-"))
        > new Date(phEndTime.replace("/", "-").replace("/", "-"))) {
        layer.msg("采购费用开始时间不能大于结束时间", { time: 1000 });
        return;
    }

    var pdLineCodes = "";
    if (!$("#pdLine").is(":hidden") && $("#pdLine").val() != undefined) {
        $("#pdLine").find("input[type='checkbox']:checked").each(function (i, n) {
            if (i == 0) {
                pdLineCodes += $(n).val();
            } else {
                pdLineCodes += "," + $(n).val();
            }
        });
        if (pdLineCodes == "") {
            layer.msg("至少选择一个产品线", { time: 1000 });
            return;
        }
    }

    var arr = $("form").serializeArray();
    var data = {};
    // var cusName =  $("#cus").find("option:selected").text();
    // data.cusName = cusName;
    for (var i = 0; i < arr.length; i++) {
        data[arr[i].name] = arr[i].value;
    };
    data.fileId = fileId;
    if ($$scope.type == "XS") {
        var ocusName = $("#cus").val();
        var cusName = ocusName.split("-----");
        data.cusName = cusName[0];
    }
    if ($$scope.proType == "BM") {
        data.clueLv = 2;
    }
    data.proType = $$scope.type;
    data.newMoney = newMoneyArr;
    data.delMoney = delL;
    data.pdLineCodes = pdLineCodes;
    data.rlData = rlData;
    data.delRl = delRl;
    data.wjData = wjData;
    data.delWj = delWj;
    // 开启
    var index = layer.load(1);
    $CertusFormAjax.ajax("editClue", { "params": JSON.stringify(data), "stepId": stepId, "procssId": processId }, function (response) {
        // 关闭
        layer.close(index);
        layer.msg("提交成功！");
        window.history.back();
    });
});

function showRl() {
    $(".hiderl").show();
}
function showWj() {
    $(".wjhider").show();
};
function cleanRl() {
    $("#rluserName").val("");
    $("#rlBeginTime").val("");
    $("#rlEndTime").val("");
    $("#rlComments").val("");
};
function cleanWj() {
    $("#wjName").val("");
    $("#wjComments").val("");
};
function daysBetween(sDate1,sDate2){
    //Date.parse() 解析一个日期时间字符串，并返回1970/1/1 午夜距离该日期时间的毫秒数
    var time1 = Date.parse(new Date(sDate1));
    var time2 = Date.parse(new Date(sDate2));
    var nDays = Math.abs(parseInt((time2 - time1)/1000/3600/24));
    return  nDays;
};